<?php

namespace app\common\service\lib\sms;

class Sms
{
    /**
     * Author:Zhongyuan Lu
     * 工厂模式发送验证码
     * @param $phone
     * @param $code
     * @return array
     */
    public static function sendSms($phone,$code)
    {
        $SmsFactory = new SmsFactory();
        if (config('setting.Sms.default') == 'ronglian') {
            //容联云发送验证码
            $Sms = $SmsFactory->createSms(SmsRongLian::class);
            $tempId = config('setting.Sms.ronglian.tempId');
            return $Sms->sendSms($phone, ['code' => $code], $tempId);
        } elseif (config('setting.Sms.default') == 'duanxinbao') {
            //短信宝发送验证码
            $Sms = $SmsFactory->createSms(SmsTreasure::class);
            return $Sms->sendSms($phone, $code);
        }
        return ['code' => 400, 'data' => [], 'message' => '配置有误'];
    }
}